<template>
    <div class="container">
        <Mysearch @sendseach='receivesearch' @sendstatus='receivestatus' @sendtime='receivetime' />
        <Mytable :list='list' />
        <Page :page='page' :pageSize='pageSize' :total='total'
        @handleCurrentChange='handleCurrentChange'/>
    </div>
</template>
<script>
import Mysearch from './components/Mysearch.vue'
import Mytable from './components/Mytable.vue'
import {getWorkData} from '../../api/workApi'
export default {
    data () {
        return {
            list:[],
            keyword:'',
            page:1,
            pageSize:9,
            total:0,
            statusnum:'',
            stime:'',
            etime:''
        }
    },
    components: {
        Mysearch,
        Mytable
    },
    mounted () {
        this.initworkdata()
    },
    methods: {
        initworkdata(){
            getWorkData({keyword:this.keyword,page:this.page,pageSize:this.pageSize,statusnum:this.statusnum,stime:this.stime,etime:this.etime}).then(res=>{
                console.log(res);
                // console.log(+new Date(res.data[0].date));
                if(res.code==200){
                    this.list=res.data;
                    this.total=res.total;
                }
            })
        },
        receivesearch(val){
            this.keyword=val;
            this.initworkdata();
        },
        receivestatus(val){
            this.statusnum=val;
            this.initworkdata();
        },
        handleCurrentChange(val){
            this.page=val;
            this.initworkdata();
        },
        receivetime(val){
            // console.log(val[0].getTime());
            // console.log(val[1].getTime());
            if(val==null){
                this.stime='';
                this.endtime='';
            }else{
                var time1=val[0].getTime();
                var time2=val[1].getTime();
                this.stime=time1;
                this.etime=time2;
            }
            this.initworkdata();
        }
    }
}
</script>
<style lang="less" scoped>
    .container{
        overflow: hidden;
        background: #fff;
        border: 1px solid #eee;
        border-radius: 10px;
        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    }
</style>